import { ExecutionContext, NestInterceptor } from "@nestjs/common";
import {
  Observable,
  tap,
  map,
} from "rxjs";


// 通过拦截器来改变路由处理函数的响应结果
export class TransformInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next): Observable<any> | Promise<Observable<any>> {
    console.log('TransformInterceptor start')
    return next.handle().pipe(
      map(data => {
        console.log('TransformInterceptor end', data)
        return { data }
      })
    )
  }

}
